package com.ktjy.anno;

import java.lang.reflect.Field;

public class FruitInfoUtil {
    public static void getFruitInfo(Class<?> clazz) {
        //通过类的类型获得类的所有属性
        Field[] declaredFields = clazz.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println(declaredField);
            //getAnnotation搜索该属性上是否有某个注解
            FruitName fruitName = declaredField.getAnnotation(FruitName.class);
            System.out.println(fruitName.value());
        }
    }
}
